//package services
//
//import play.api.libs.ws.WS
//import play.api.libs.concurrent.Execution.Implicits.defaultContext
//import java.util.HashMap
//import scala.collection.JavaConversions._
//import akka.actor.Actor
//import play.db.jpa.JPA
//import play.libs.F
//import play.api.libs.concurrent.Akka
//import play.api.Play.current
//import akka.actor.Props
//import play.api.libs.json.Json
//import models.Mensaje
//
//class NotificationSenderScala extends Actor {
//  def receive = {
//    //    case _ => JPA.withTransaction(new F.Function0[String] {
//    //      def apply = {
//    //        val x = DAO.executeNative("""
//    //            SELECT id_android FROM users where id_android is not null""", -1).asInstanceOf[java.util.Vector[String]].mkString(" ");
//    //        println(x);
//    //        ""
//    //      }
//    //    });
//    case Notification(recipients, notification) => {
//
//      val androidIds: String = "\"" ++ recipients.flatMap(_.registrationIds).mkString(",") ++ "\""; ;
//      s"""
//      "registration_ids":[$androidIds],
//      "data":${
//        notification match {
//          case men: MensajeN => {
//            Json.toJson(men)(Json.writes[MensajeN]).toString
//          }
//
//        }
//      }
//      """
//    }
//  }
//}
//
//object NotificationsSrvScala {
//  val actor = Akka.system.actorOf(Props[NotificationSenderScala], name = "NotificationSender");
//
//  val key = "AIzaSyCTxQYkcHDRNQNAGNPT7lam68no_wTMooI";
//
//  def notifySomething2 {
//    println("https://android.googleapis.com/gcm/send");
//    val ids = DAO.executeNative("""
//        select id_android from users where id_android is not null
//        """, -1).asInstanceOf[java.util.Vector[String]].mkString("""","""")
//    val future = WS.url("https://android.googleapis.com/gcm/send").withHeaders(
//      "Content-Type" -> "application/json",
//      "Authorization" -> ("key=" ++ key)).post(s"""{
//    		  	"registration_ids" : ["$ids"],
//    		  	"data" : {"haha":"YEISSON GAY"}
//    		  }""");
//    future.map({ f =>
//      println(f.body);
//    })
//  }
//
//  def notifySomething(recipients: List[Recipient], n: NotificationData) {
//    actor ! Notification(recipients, n);
//  }
//
//}
//case class Notification(recipients: List[Recipient], n: NotificationData)
//abstract class NotificationData {
//
//}
//case class MensajeN(id: Long, preview: String) extends NotificationData {
//
//}
//
//abstract class Recipient {
//  def registrationIds: Seq[String]
//}
//case class CursoR(id: Long) extends Recipient {
//  def registrationIds: Seq[String] = {
//    Seq()
//  }
//}
//case class GradoR(id: Long, idColegio: Long) extends Recipient {
//  def registrationIds: Seq[String] = {
//    Seq()
//  }
//}
//case class EstudianteR(id: Long) extends Recipient {
//  def registrationIds: Seq[String] = {
//    Seq()
//  }
//}
//case class ColegioR(id: Long) extends Recipient {
//  def registrationIds: Seq[String] = {
//    Seq()
//  }
//}